<%--
  Created by IntelliJ IDEA.
  User: tao95
  Date: 2017/5/7
  Time: 18:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    String staticPath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort();
%>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title>网站信息</title>
    <link rel="stylesheet" href="/static/css/pintuer.css">
    <link rel="stylesheet" href="/static/css/admin.css">
    <script src="/static/js/jquery.js"></script>
    <script src="/static/js/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 管理员列表</strong></div>
    <div class="padding border-bottom">
        <a class="button border-yellow" href="#" onclick = "addAdmin()"><span class="icon-plus-square-o"></span> 添加内容</a>
    </div>
    <table class="table table-hover text-center">
        <tr>
            <th>管理员名</th>
            <th>管理员电话</th>
            <th>管理员email</th>
            <th width="250">操作</th>
        </tr>
    <c:forEach var="item" items="${adminList}">
        <tr>
            <input type="hidden" name="id"  value="${item.id}" />
            <td>${item.userName}</td>
            <td>${item.phone}</td>
            <td>${item.email}</td>
            <td>
                <div class="button-group">


                    <a type="button" class="button border-main" href="#" onclick="editAdmin(${item.id},'${item.userName}','${item.phone}','${item.email}');"><span class="icon-edit" ></span>修改</a>
                    <a class="button border-red" href="javascript:void(0)" onclick="return del(${item.id})"><span class="icon-trash-o"></span> 删除</a>
                </div>
            </td>
        </tr>
    </c:forEach>

    </table>
</div>
<script>
    function addAdmin(){
        $("#hidden").val("");
        $("#userName").val("");
        $("#phone").val("");
        $("#email").val("");
        $("#pass").show();
    }
    function del(id){
        if(confirm("您确定要删除吗?")){
            window.location.href = "/user/delAdmin?id="+id;
        }
    }
    function editAdmin(id,userName,phone,email){
        console.log("id="+id+" userName="+userName+" phone="+phone+" email="+email);
        $("#hidden").val(id);
        $("#userName").val(userName);
        $("#phone").val(phone);
        $("#email").val(email);
        $("#pass").hide();
    }
</script>
<div class="panel admin-panel margin-top">
    <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>增加内容</strong></div>

    <div class="body-content">
        <form method="post" class="form-x" action="<%=basePath %>user/addAdmin">
            <input type="hidden" name="id"  value=""  id="hidden"/>
            <div class="form-group">
                <div class="label">
                    <label>管理员姓名：</label>
                </div>
                <div class="field">
                    <input type="text" class="input" name="userName" value="" id="userName"/>
                    <div class="tips"></div>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label>手机：</label>
                </div>
                <div class="field">
                    <input type="text" class="input" name="phone" value="" id="phone"/>
                    <div class="tips"></div>
                </div>
            </div>


            <div class="form-group">
                <div class="label">
                    <label>Email：</label>
                </div>
                <div class="field">
                    <input type="text" class="input" name="email" value="" id="email"/>
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group" id="pass">
                <div class="label">
                    <label>密码：</label>
                </div>
                <div class="field">
                    <input type="text" class="input" name="password" value="初始密码123456"  disabled="true" />
                    <div class="tips"></div>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label></label>
                </div>
                <div class="field">
                    <c:if test="${requestScope.addPass == 'success'}">
                        <button class="button bg-main icon-check-square-o" type=""> 添加成功</button>
                    </c:if>
                    <c:if test="${requestScope.addPass == 'fail'}">
                        <button class="button bg-main icon-check-square-o" type=""> 添加失败</button>
                    </c:if>
                    <button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
                </div>
            </div>
        </form>
    </div>
</div>
</body></html>
